﻿<UserControl xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"  
             xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"  
             x:Class="predic.Web2.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:domain="clr-namespace:predic.Web.Host.Services"
    mc:Ignorable="d"
    d:DesignHeight="400" 
             d:DesignWidth="700" 
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">
    <toolkit:BusyIndicator x:Name="BusyIndicator" IsBusy="{Binding ElementName=StudiesView, Path=IsBusy}">
        <Grid x:Name="LayoutRoot" Background="White" KeyDown="LayoutRoot_KeyDown">

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <riaControls:DomainDataSource x:Name="StudiesView" QueryName="GetStudiesViewQuery"
                                          AutoLoad="True" LoadSize="120" PageSize="40">
                <riaControls:DomainDataSource.DomainContext>
                    <domain:PredicContext />
                </riaControls:DomainDataSource.DomainContext>
                
                <!--<riaControls:DomainDataSource.GroupDescriptors>
                    <riaControls:GroupDescriptor Property />
                </riaControls:DomainDataSource.GroupDescriptors>-->
            </riaControls:DomainDataSource>

            <Grid  Grid.Column="1">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <sdk:DataGrid Grid.Row="0" Name="GridPredici" AutoGenerateColumns="False"
                              RowDetailsVisibilityMode="VisibleWhenSelected" 
                              Margin="5" BorderThickness="0" IsReadOnly="True"
                              ItemsSource="{Binding Path=Data, ElementName=StudiesView}" SelectionMode="Single"
                              KeyDown="LayoutRoot_KeyDown">
                    <sdk:DataGrid.Columns>
                        <sdk:DataGridTextColumn Width="*" Header="Nume" Binding="{Binding Path=FirstName}" />
                        <sdk:DataGridTextColumn Width="*" Header="Prenume" Binding="{Binding Path=LastName}" />
                        <sdk:DataGridTextColumn Width="*" Header="Studiu" Binding="{Binding Path=Title}" />
                        <sdk:DataGridTextColumn Width="*" Header="Predica" Binding="{Binding Path=Subtitle}" />
                        <sdk:DataGridTextColumn Width="*" Header="Text" Binding="{Binding Path=Text}" />
                        <sdk:DataGridTextColumn Width="*" Header="Tematica" Binding="{Binding Path=Tematica}" />
                        <sdk:DataGridTextColumn Width="*" Header="Subiect" Binding="{Binding Path=Subiect}" />
                    </sdk:DataGrid.Columns>

                    <sdk:DataGrid.RowDetailsTemplate>
                        <DataTemplate>
                            <Border Padding="10" Margin="20" Height="100" Background="Gray">
                                <StackPanel>
                                    <StackPanel Margin="4" Orientation="Horizontal">
                                        <TextBlock Text="Studiu" 
                                           Style="{StaticResource RowDetailTitle}" Margin="5,0,5,0" />
                                        <TextBlock Text="{Binding Path=Title}"
                                           Margin="5,0,5,0" Style="{StaticResource RowDetailInformation}"/>

                                        <TextBlock Text="Predica" 
                                           Style="{StaticResource RowDetailTitle}" Margin="5,0,5,0" />
                                        <TextBlock Text="{Binding Path=Subtitle}"
                                           Margin="5,0,5,0" Style="{StaticResource RowDetailInformation}"/>

                                        <TextBlock Text="Tematica" 
                                           Style="{StaticResource RowDetailTitle}" Margin="5,0,5,0" />
                                        <TextBlock Text="{Binding Path=Tematica}"
                                           Margin="5,0,5,0" Style="{StaticResource RowDetailInformation}"/>
                                    </StackPanel>
                                    <StackPanel Margin="4" Orientation="Horizontal">
                                        <Button x:Name="btnEditStudy" Content="Edit" Width="90" Click="btnEditStudy_Click" />
                                        <Button x:Name="btnDeleteStudy" Content="Delete" Width="90" Click="btnDeleteStudy_Click" />
                                    </StackPanel>
                                </StackPanel>
                            </Border>
                        </DataTemplate>
                    </sdk:DataGrid.RowDetailsTemplate>
                </sdk:DataGrid>
                <sdk:DataPager Grid.Row="1" x:Name="DataPager"  PageSize="40"
                           Source="{Binding Path=ItemsSource, ElementName=GridPredici}" />
            </Grid>


            <StackPanel Name="MenuStackPanel" Margin="5" HorizontalAlignment="Left">

                <Border Margin="2">
                    <StackPanel Orientation="Horizontal">
                        <Button Content="Catalogs" Width="90"/>
                    </StackPanel>
                </Border>

                <Border Margin="2" Width="160">
                    <StackPanel>
                        <TextBlock Text="Predicator" Margin="2" />
                        <sdk:AutoCompleteBox MinimumPrefixLength="0" x:Name="filterPredicator" Margin="2" />
                    </StackPanel>
                </Border>

                <Border Margin="2" Width="160">
                    <StackPanel>
                        <TextBlock Text="Studiu" Margin="2" />
                        <sdk:AutoCompleteBox MinimumPrefixLength="0" x:Name="filterStudiu" Margin="2" />
                    </StackPanel>
                </Border>

                <Border Margin="2" Width="160">
                    <StackPanel>
                        <TextBlock Text="Predica" Margin="2" />
                        <sdk:AutoCompleteBox MinimumPrefixLength="0" x:Name="filterPredica" Margin="2" />
                    </StackPanel>
                </Border>

                <Border Margin="2" Width="160">
                    <StackPanel>
                        <TextBlock Text="Text" Margin="2" />
                        <sdk:AutoCompleteBox x:Name="filterText" Margin="2" />
                    </StackPanel>
                </Border>

                <Border Margin="2" Width="160">
                    <StackPanel>
                        <TextBlock Text="Tematica" Margin="2" />
                        <sdk:AutoCompleteBox x:Name="filterTematica" Margin="2" />
                    </StackPanel>
                </Border>

                <!--<Border Margin="2" Width="160">
                    <StackPanel>
                        <TextBlock Text="Tematica" Margin="2" />
                        <sdk:AutoCompleteBox Margin="2" />
                    </StackPanel>
                </Border>-->

                <Border Margin="2">
                    <StackPanel Orientation="Horizontal">
                        <Button x:Name="btnFilter" Content="Filter" Width="90" Click="btnFilter_Click"/>
                    </StackPanel>
                </Border>

            </StackPanel>
        </Grid>
    </toolkit:BusyIndicator>
</UserControl>
